package android.cmpe451.group7.activity;

import java.util.HashMap;

import android.cmpe451.group7.activity.R;

import android.app.Activity;
import android.cmpe451.group7.util.SessionManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

/**
 * Creates user option page with there options: Search Place, Profile, Create Place.
 *
 */
public class UserOptionActivity extends Activity {

	SessionManager session;
	Button btnLogout;

	@Override
	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		// setting default screen to login.xml
		setContentView(R.layout.user_option);

		TextView emailTextView = (TextView) findViewById(R.id.lblEmail);
		Button buttonSearchPlace = (Button) findViewById(R.id.buttonSearchPlace);
		Button buttonInsertPlace = (Button) findViewById(R.id.buttonInsertPlace);
		Button buttonProfile = (Button) findViewById(R.id.buttonProfile);
		btnLogout = (Button) findViewById(R.id.buttonLogout);

		session = new SessionManager(getApplicationContext());
		session.checkLogin();

		HashMap<String, String> user = session.getUserDetails();
		String name = user.get(SessionManager.KEY_NAME);

		emailTextView.setText(name);

		buttonSearchPlace.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent i = new Intent(getApplicationContext(),
						SearchActivity.class);
				startActivity(i);
			}
		});

		buttonInsertPlace.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent i = new Intent(getApplicationContext(),
						CreatePlaceActivity.class);
				startActivity(i);
			}
		});
		buttonProfile.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent i = new Intent(getApplicationContext(),
						UserProfileActivity.class);
				startActivity(i);
			}
		});

		btnLogout.setOnClickListener(new View.OnClickListener() {
			public void onClick(View arg0) {
				session.logoutUser();
			}
		});
	}
}
